package com.zunipe.screen;

import com.zunipe.until.Util;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.CyclingButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;

public class OptionScreen extends Screen
{
    private final Screen parent;

    public OptionScreen(Screen screen)
    {
        super(new LiteralText("设置"));
        this.parent = screen;
    }

    @Override
    protected void init()
    {
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 168, 200, 20, ScreenTexts.DONE, button -> this.client.setScreen(this.parent)));
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 143, 200, 20, new LiteralText("自动攻击设置"), button -> this.client.setScreen(new AutoAttackOptionScreen(this))));
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 118, 200, 20, new LiteralText("垃圾桶扫描者设置"), button -> this.client.setScreen(new ScanningBoxOptionScreen(this))));
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 93, 200, 20, new LiteralText("连点器设置"), button -> this.client.setScreen(new AutoClickOptionScreen(this))));
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 93 - 25, 200, 20, new LiteralText("矿物透视设置"), button -> this.client.setScreen(new XrayOptionScreen(this))));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Util.autoRedPacket)).build(this.width / 2 - 100, this.height / 6 + 93 - 50, 200, 20, new LiteralText("自动抢红包"), (a, b) -> Util.autoRedPacket = b.getSwitch()));
    }

    @Override
    public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
    {
        this.renderBackground(matrices);
        OptionsScreen.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 0xFFFFFF);
        super.render(matrices, mouseX, mouseY, delta);
    }
}
